BuffEffect6 = BaseBuffEffect:new();
BuffEffect6.__index = BuffEffect6;

function BuffEffect6:new()
    local object = {};
    setmetatable(object, BuffEffect6);
    return object;
end

function BuffEffect6:add(fight,buff)
    local fighter = null;
    local buffEffectValue = decodeJsonStrToTabel(buff.buffBean.f_BuffEffectValue);
    if buffEffectValue[2] == 0 then
        fighter = buff.source;
    else
        fighter = buff.target;
    end
    -- 增加护盾
    local value = Mathf.Floor(FighterAttributeManager.getFightAttr(fighter,buffEffectValue[3]) * buffEffectValue[4] / EnumConst.TEN_THOUSANDTH + buffEffectValue[1]);       
    buff.parameter = {value};
    fightLog("[EFFECT]Fighter "..buff.target.fighterId.." Buff"..buff.modelId.." 增加护盾BUFF效果，护盾值："..buff.parameter[1]);

    if buff.target ~= nil then
        buff.target:setShield(tonumber(buff.parameter[1]));
    end

    return BaseBuffEffect:add(fight, buff);
end


function BuffEffect6:action(fight,buff,...)
    local result = select('3',...);
    local skill = select('2',...);
    local skillBean = skill.skill.skillBean;

    if skillBean.f_HurtMethod == EnumConst.SkillDamageTypeEnum.HEAL then
        return EnumConst.IBuffEffect.SUCCESS;
    end

    if result.damage <= 0 then
        return EnumConst.IBuffEffect.SUCCESS;
    end

    fightLog("[EFFECT]Fighter "..buff.target.fighterId.." Buff"..buff.modelId.." 触发护盾BUFF效果，护盾值："..buff.parameter[1]);

    if result.damage >= buff.parameter[1] then
        result.damage = result.damage - buff.parameter[1];
        buff.parameter[1] = 0;
    else
        buff.parameter[1] = buff.parameter[1] - result.damage;
        result.damage = 0;
    end

    fightLog("[DAMAGE]"..buff.source.fighterId.."对"..buff.target.fighterId.."计算BUFF("..buff.modelId..")减伤伤害[4]结果"..subDigitalNum(result.damage,4));

    if buff.parameter[1] <= 0 then
        return EnumConst.IBuffEffect.REMOVE;
    end
    return BaseBuffEffect:action(fight, buff, ...);
end